package service.impl;

import bean.dto.ExpenseTypePage;
import bean.pojo.ExpenseType;
import bean.vo.ExpenseTypeOption;
import dao.ExpenseTypeDao;
import dao.impl.ExpenseTypeDaoImpl;
import service.ExpenseTypeService;

import java.util.List;

/**
 * service.impl
 * User: xlh
 * Date: 2024/12/17 9:52
 * motto:推到高塔
 * Description:
 * Version: V1.0
 */
public class ExpenseTypeServiceImpl implements ExpenseTypeService {
    private ExpenseTypeDao expenseTypeDao =new ExpenseTypeDaoImpl();
    @Override
    public List<ExpenseType> findByPage(ExpenseTypePage expenseTypePage) {
        return  expenseTypeDao.findByPage(expenseTypePage);
    }

    @Override
    public List<ExpenseTypeOption> findAllList() {
        return expenseTypeDao.findAllList();
    }

    @Override
    public boolean updateById(ExpenseType expenseType) {
        return expenseTypeDao.updateById(expenseType)>0;
    }

    @Override
    public boolean insert(ExpenseType expenseType) {
        return this.expenseTypeDao.insert(expenseType)>0;
    }

    @Override
    public boolean deleteById(Integer typeId) {
        return this.expenseTypeDao.deleteById(typeId)>0;
    }

    @Override
    public boolean createType(String typeName) {
        return this.expenseTypeDao.createType(typeName)>0;
    }

    public Long findByTotal(ExpenseTypePage expenseTypePage) {
        //验证有没有值
        if(expenseTypePage.getTypeTime()==null  ||  expenseTypePage.getTypeTime().trim().length()==0){
            expenseTypePage.setTypeTime(null);
        }
        return   expenseTypeDao.findByTotal(expenseTypePage);
    }
}
